<?php
// Returns an XML list of all detail data from the specified student.
// Student is specified with the primaryKey variable in the request.

session_start();
if ( ! isset( $_SESSION['adminLoggedIn'] ) ) {
   exit;
}

require_once("db.php");

// Is there data coming in?
if ( isset($_GET['primaryKey'] ) ) {
   
   $primaryKey = $_GET['primaryKey'];
   
   $sql = "
      SELECT gs_students.id as primaryKey, 
         gs_plans.id as plan_id,
         gs_plans.is_submitted,
         gs_plans.is_reviewed,
         gs_plans.is_approved,
         gs_plans.comments,
         xml as plan,
         `lastname`, 
         `firstname`, 
         `sid`, 
         `birthday`, 
         `accepted_on`, 
         `toefl`, 
         `gre_verbal`, 
         `gre_quant`, 
         `gre_aw`, 
         `university`, 
         `grade`, 
         `country`, 
         `oo_track`, 
         `se_track`, 
         `db_track`, 
         `is_track`, 
         `ds_track`, 
         `mbi_track`, 
         `email`
      FROM `gs_students` left join gs_plans
      ON gs_students.id=gs_plans.student_id
      WHERE gs_students.id=$primaryKey
   ";
  
   $result = my_mysql_query($sql);
   $row = mysql_fetch_assoc($result);
 
   // Output the result as XML.
   echo "<student>\n";
   foreach (array_keys($row) as $key) {
      echo "<$key>";
      echo stripslashes($row[$key]); 
      echo "</$key>\n";
   }
   echo "</student>\n";
   return;

}

?>